// 专门管理 .zfclirc 文件（当前用户目录下）
// zh-cli config set key  value

import { action } from 'commander';
import {
  get, set, remove, getAll,
} from './utils/rc.js';

const config = async (action, k, v) => {
  switch (action) {
    case 'get':
      if (k) {
        const key = await get(k);
        // console.log(key)
      } else {
        const obj = await getAll();
        Object.keys(obj).forEach((key) => {
          console.log(`${key}=${obj[key]}`);
        });
      }
      break;
    case 'set':
      set(k, v);
      break;
    case 'remove':
      remove(k);
      break;
    default:
      break;
  }
};
export default config;
